<?php
/**
 * Extend CustProductSite จะได้เรียกใช้ชื่อย่อ ๆ CPS ได้ ไม่ต้องเขียนเต็ม
 */
class CPS extends CustProductSite {
    var $name = 'CPS';

    function afterFind($results) {
        foreach ($results as &$cps) {
            if (isset($cps['CPS'])) {
                if (isset($cps['CPS']['min_stock_date'])) {
                    $cps['CPS']['min_stock_date'] = $this->dateFormatAfterFind($cps['CPS']['min_stock_date']);
                }
                if (isset($cps['CPS']['max_stock_date'])) {
                    $cps['CPS']['max_stock_date'] = $this->dateFormatAfterFind($cps['CPS']['max_stock_date']);
                }
                if (isset($cps['CPS']['last_stock_in_date'])) {
                    $cps['CPS']['last_stock_in_date'] = $this->dateFormatAfterFind($cps['CPS']['last_stock_in_date']);
                }
                if (isset($cps['CPS']['last_stock_out_date'])) {
                    $cps['CPS']['last_stock_out_date'] = $this->dateFormatAfterFind($cps['CPS']['last_stock_out_date']);
                }
            }
        }
        return $results;
    }
}
